home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
c2
/
pro4
/
kerror.c
< prev
next >
Wrap
Text File
|
1986-05-08
|
2KB
|
108 lines
/* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
#include <stdio.h>
#define EXTERN extern
#include <typedef.h>
#define CTRL_C '\003'
#define CTRL_M '\015'
void SetMessageOn()
{
MessageGlb = TRUE;
}
void SetMessageOff()
{
MessageGlb = FALSE;
}
void SetBreakOff()
{
BrkGlb = FALSE;
}
void SetBreakOn()
{
BrkGlb = TRUE;
}
static char *HexString(byt)
int byt;
{
static char hex[] = "0123456789ABCDEF";
static char dest[3] = " \0";
dest[0] = hex[byt >> 4];
dest[1] = hex[byt & 0x0f];
return(dest);
}
void error(ErrProc, ErrCode)
int ErrProc, ErrCode;
{
int NLevels, PCValue, XLoc, YLoc;
char Ch;
if (!((ErrProc >= 0) && (ErrProc <= MaxProcsGlb))) {
LeaveGraphic();
fprintf(stderr, "FATAL ERROR 1: illegal procedure number %d.\n",
ErrProc);
exit(1);
}
if (!((ErrCode >= 0) && (ErrCode <= MaxErrsGlb))) {
LeaveGraphic();
fprintf(stderr, "FATAL ERROR 2: illegal error code %d.\n", ErrCode);
exit(1);
}
ErrCodeGlb = ErrCode;
if (BrkGlb)
LeaveGraphic();
if (MessageGlb || BrkGlb) {
XLoc = XTextGlb;
YLoc = YTextGlb;
GotoXY(1,24);
ClrEOL();
fprintf(stderr, "Graphix error #%d in procedure #%d",
ErrCode, ErrProc);
if (MessageGlb) {
ClrEOL;
fprintf(stderr, "(%s in %s)\n",
ErrorCode[ErrCode], ErrorProc[ErrProc]);
}
}
if (BrkGlb && !MessageGlb)
exit(1);
if (MessageGlb) {
fprintf(stderr, ". Hit enter: ");
do {
Ch = inkey();
} while ((Ch != CTRL_M) && (Ch != CTRL_C));
if (Ch == CTRL_C) {
LeaveGraphic();
exit(1);
}
GotoXY(XLoc,YLoc);
}
}
int GetErrorCode()
{
int retc;
retc = ErrCodeGlb;
ErrCodeGlb = 0;
return(retc);
}